home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2008 June / Macworld June 2008 CD.bin / LogMeIn / LogMeInMac.dmg / LogMeIn Installer.pkg / Contents / Resources / test_for_old_version.pl < prev   
Encoding:
Text File  |  2008-01-29  |  1.1 KB  |  39 lines

  1. # http://jira/browse/LMIMAC-140
  2. # This code is for working around a bug in Tiger Installer that causes the 
  3. # wrong version to be installed if both versions are mounted with the same name
  4.  
  5. use FindBin;
  6. use File::Basename;
  7.  
  8. my $path = $FindBin::Bin;
  9.  
  10. my $pkgdir = dirname(dirname($path));
  11. my $relpkgpath = basename($pkgdir);
  12. my $path = dirname($pkgdir);
  13. my $name = basename($path);
  14.  
  15. my $infoplistrelpath = '/Contents/Info.plist';
  16. my $pattern = '^LogMeIn Installer( \d+)?$';
  17. my $pathpattern = '^/Volumes/LogMeIn Installer( \d+)?$';
  18.  
  19. my $volumesdir = '/Volumes';
  20. my $origippath = $pkgdir.$infoplistrelpath;
  21.  
  22. if ($path =~ /$pathpattern/) {
  23.     opendir(DIR, $volumesdir) || die "can't opendir $volumesdir: $!";
  24.         @items = grep { /$pattern/ } readdir(DIR);
  25.     closedir DIR;
  26.     
  27.     for my $i (@items) {
  28.         my $actippath = $volumesdir.'/'.$i.'/'.$relpkgpath.$infoplistrelpath;
  29.         print("ERR:".$actippath);
  30.         my @args = ("/usr/bin/cmp",$actippath,$origippath);
  31.         system(@args) == 0
  32.              or die "system @args failed: $?";
  33.         if (($? >> 8) == 1) {
  34.             print "Found different versions of Info.plist at $actippath $origippath\n";
  35.             exit(13);
  36.         }
  37.     }
  38. }
  39. exit(0);